Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Not to Pull. Just discussion] adding some C++11 aspects and a HOT tracer #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lookfwd
Copy link

@lookfwd lookfwd commented Jan 25, 2017

This adds some draft implementations of a Higher Order Tracer and demonstrate how you can do a C++11 wrapper (that should be provided by OT / shouldn't be app-specific).

template <typename Args>
inline std::shared_ptr<Span> start(Args & args)
{
return std::shared_ptr<Span>(tracer.start(args), [this](Span *pi) { tracer.cleanup(pi); });
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to optimize the deleter method somehow (static?)

typedef NoopTracer ZipkinV1;
typedef NoopTracer ZipkinV2;

// Setting up stuff... Would be nice if they weren't that many...
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quoting the comment

Would be nice if they weren't that many... is there any way GenericTracer to deduce those from just MyHotTracer?

#include <tracing_cpp11.h>

// Now we "upgrade" the entire system to C++11. Yeiii!
typedef Cpp11Tracer<GlobalTracer> Cpp11GlobalTracer;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming it just Tracer would make thing even more pretty.

@@ -0,0 +1,297 @@
#ifndef INCLUDED_OPENTRACING_HOT_H
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclaimer: I did just some of Span, Context and Tracer. It's not a complete implementation.

};


/**
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quoting the comment

VERY TRICKY. Pay attention to const-ness here. Span's context mustn't be const but extract()'s has to be const. To be properly thought/implemented.

t2.inject(carrier, *span.span2);
}

return 0;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be the return value here?


void cleanupImp(const HotOptions<T1,T2>* ob)
{
if (ob)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Think can remove those if's.

// Application code
auto tracer = Cpp11GlobalTracer::instance();

auto span = tracer.start("hi");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and ctx below are std::shared_ptr's i.e. there's no mem leak here.


auto span = tracer.start("hi");

std::vector<opentracing::TextMapPair> pairs;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that this compiles but it likely means we have a bit too much freedom. I guess here's what's most of the discussion about. I guess both ZipkinV1 and ZipkinV2 should support something that serializes to text and http headers. If there's a proprietary IPC extension that ZipkinV1 supported, I guess that ZipkinV2 should support it as well to be backwards compatible, so no harm. If instead we had ZipkinV1 and Jaeger, then I can see that Jaeger might not support the proprietary IPC extension (out of the box). It would be nice to be able to #include a single header file (with potentially infinite uglyness) and extend your Jaeger tracer to support the proprietary IPC. If this isn't possible, I guess the next alternative is to git-clone Jaeger and add support to it. In any case, for as long as Jaeger` doesn't support your custom IPC, the custom IPC infrastructure should be able to pretend it's a standard "HTTP" or "TEXT" type and it should work out of the box with potentially some inferior performance.

return std::shared_ptr<const SpanContext>(tracer.extract(carrier), [this](const SpanContext *pi) { tracer.cleanup(pi); });
}

static Cpp11Tracer instance()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this doesn't return a shared_ptr. It might be better if it did.

@sureshbalakundi
Copy link

Hi,
i need to Use OpenTracing-cpp in My project. i have my own main function. i already installed Opentracing-cpp . how to use Opentracing can you provide me some cpp example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants